<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>协议管理</title>
    <#assign base=request.contextPath  />
    <link rel="stylesheet" href="${base}/admin/MyStatic/frame/layui/css/layui.css" media="all">
    <script type="text/javascript" src="${base}/admin/MyStatic/js/zhang.js"></script>

    <script src="${base}/admin/MyStatic/js/wangEdit/wangEditor.js"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>协议管理</legend>
</fieldset>
<div class="layui-collapse" lay-accordion="">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">用户协议</h2>
        <div class="layui-colla-content  ">
            <div id="toobar_1" class="toolbar"></div>
            <blockquote class="layui-elem-quote layui-quote-nm">
                <div id="text_1" class="text">
                    <#if agreenment.code==0>
                        <#list agreenment.data as list>
                            <#if list.type==1>
                                <#assign text_1=list.id  />
                                ${list.content}
                            </#if>
                        </#list>
                    </#if>
                </div>
            </blockquote>
            <button class="layui-btn layui-btn-fluid" type="button" id="text_1Btn">
                <i class="layui-icon  layui-icon-ok">确认修改</i>
            </button>
        </div>
    </div>
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">法律协议</h2>
        <div class="layui-colla-content ">
            <div id="toobar_2" class="toolbar"></div>
            <blockquote class="layui-elem-quote layui-quote-nm">
                <div id="text_2" class="text">
                     <#if agreenment.code==0>
                        <#list agreenment.data as list>
                            <#if list.type==2>
                                <#assign text_2=list.id  />
                                ${list.content}
                            </#if>
                        </#list>
                     </#if>
                </div>
            </blockquote>
            <button class="layui-btn layui-btn-fluid" type="button" id="text_2Btn">
                <i class="layui-icon  layui-icon-ok">确认修改</i>
            </button>
        </div>
    </div>
</div>
<script src="${base}/admin/MyStatic/js/jquery.min.js"></script>
<script src="${base}/admin/MyStatic/frame/layui/layui.js"></script>
<script>
    layui.use(['element', 'layer'], function () {
        var element = layui.element;
        var layer = layui.layer;


        var E1 = window.wangEditor;
        var editor1 = new E1('#toobar_1', '#text_1');
        var E2 = window.wangEditor;
        var editor2 = new E2('#toobar_2', '#text_2');

        initEdit();

        //配置富文本
        function initEdit() {
            editor1.customConfig.zIndex = 100;
            editor1.customConfig.uploadImgServer = '${base}/admin/sysAgreement/upload';  // 上传图片到服务器
            editor1.customConfig.uploadFileName = 'file'
            editor1.customConfig.uploadImgMaxLength = 1
            editor1.create();
            editor2.customConfig.uploadImgServer = '/upload';  // 上传图片到服务器
            editor1.customConfig.uploadFileName = 'file';
            editor1.customConfig.uploadImgMaxLength = 1;
            editor2.create()


        }

        $("#text_1Btn").on('click', function () {
            sub(editor1.txt.html(),1,'${text_1!''}')
        });

        $("#text_2Btn").on('click', function () {
            sub(editor2.txt.html(),2,'${text_2!''}')
        });
function sub(content,type,id){

    $.ajax({
        type: "POST", //提交方式
        data: {id:id,content:content , type: type},
        url: "${base}/admin/sysAgreement/insertAgreement",//路径
        async: false,
        dataType:"json",
        success: function (data) {//返回数据根据结果进行相应的处理
            layer.msg(data.msg)
        }
    });
}

    })


</script>
</body>
</html>